package com.llcbenwu.config;



import com.llcbenwu.generator.ImageCodeService;
import com.llcbenwu.generator.SmsCodeSendService;
import com.llcbenwu.generator.impGenerator.ImageCodeServiceImpl;
import com.llcbenwu.generator.impGenerator.SmsCodeSendServiceImpl;
import com.llcbenwu.logOut.LlcLogOutSuccessHandler;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;


@Configuration
public class WebConfig {

//
//    /**
//     * 如果接第三方的过滤器就用这个
//     * @author lilinchun
//     * @date 2021/10/21 0021 18:03
//     */
//    @Bean
//    public FilterRegistrationBean timeFilter(){
//        FilterRegistrationBean registrationBean = new FilterRegistrationBean();
//        TimeFilter timeFilter = new TimeFilter();
//        registrationBean.setFilter(timeFilter);
//        //在哪些路径起作用
//        List<String> urls = new ArrayList<>();
//        urls.add("/*");
//        registrationBean.setUrlPatterns(urls);
//
//        return registrationBean;
//    }

    /**
     * 这里是一个生成验证码的一个方法
     * @return
     */
    @Bean
    @ConditionalOnMissingBean(name = "imageValidateCodeGenerator")  //如果有人重新写了一个叫imageValidateCodeGenerator那么就会覆盖该方法
    public ImageCodeService imageValidateCodeGenerator() {
        return new ImageCodeServiceImpl();
    }


    /**
     * 这里是一个生成手机验证码的一个方法
     * @return
     */
    @Bean
    @ConditionalOnMissingBean(name = "smsValidateCodeGenerator")  //如果有人重新写了一个叫imageValidateCodeGenerator那么就会覆盖该方法
    public SmsCodeSendService smsValidateCodeGenerator() {
        return new SmsCodeSendServiceImpl();
    }



    /**
     * 这里是一个生成手机验证码的一个方法
     * @return
     */
    @Bean
    @ConditionalOnMissingBean(name = "logOutSuccessHandler")  //如果有人重新写了一个叫logOutSuccessHandler那么就会覆盖该方法
    public LogoutSuccessHandler logOutSuccessHandler() {
        return new LlcLogOutSuccessHandler();
    }

}
